<?php

namespace app\admin\controller;
use app\admin\model\ArticleModel;
use app\admin\model\ArticleCateModel;
use think\Db;

class Article extends Base
{
    /**
     */
    public function patent(){

        $key = input('key');
        $map = [];
        if($key&&$key!==""){
            $map['title'] = ['like',"%" . $key . "%"];          
        }       
        $Nowpage = input('get.page') ? input('get.page'):1;
        $limits = 10;// 获取总条数
        $count = Db::name('article')->where('cate_id','=',1)->count();//计算总页面
        $allpage = intval(ceil($count / $limits));
        $patent = new ArticleModel();
        $lists = $patent->getPatentByWhere($map, $Nowpage, $limits);
        $this->assign('Nowpage', $Nowpage); //当前页
        $this->assign('allpage', $allpage); //总页数
        $this->assign('count', $count); 
        $this->assign('val', $key);
        if(input('get.page')){
            return json($lists);
        }
        return $this->fetch();
    }
    /**
     * [add_article 添加文章]
     */
    public function add_patent()
    {
        if(request()->isAjax()){

            $param = input('post.');
            $patent = new ArticleModel();
            $flag = $patent->insertPatent($param);
            return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
        }

        $cate = new ArticleCateModel();
        $this->assign('cate',$cate->getAllCate());
        return $this->fetch();
    }
    /**
     * [edit_article 编辑文章]
     */
    public function edit_patent()
    {
        $patent = new ArticleModel();
        
        if(request()->isAjax()){

            $param = input('post.');         
            $flag = $patent->updatePatent($param);
            return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
        }

        $id = input('param.id');
        $cate = new ArticleCateModel();
        $this->assign('cate',$cate->getAllCate());
        $this->assign('patent',$patent->getOnePatent($id));
        return $this->fetch();
    }
    /**
     * [del_article 删除文章]
     */
    public function del_patent()
    {
        $id = input('param.id');
        $cate = new ArticleModel();
        $flag = $cate->delPatent($id);
        return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
    }
    /**
     * [article_state 文章状态]
     */
    public function patent_state()
    {
        $id=input('param.id');
        $status = Db::name('article')->where(array('id'=>$id))->value('status');//判断当前状态情况
        if($status==1)
        {
            $flag = Db::name('article')->where(array('id'=>$id))->setField(['status'=>0]);
            return json(['code' => 1, 'data' => $flag['data'], 'msg' => '已禁止']);
        }
        else
        {
            $flag = Db::name('article')->where(array('id'=>$id))->setField(['status'=>1]);
            return json(['code' => 0, 'data' => $flag['data'], 'msg' => '已开启']);
        }
    
    }
    //*********************************************新闻中心2*********************************************//
    /**
     *首页
     */
    public function agent(){

        $key = input('key');
        $map = [];
        if($key&&$key!==""){
            $map['title'] = ['like',"%" . $key . "%"];
        }
        $Nowpage = input('get.page') ? input('get.page'):1;
        $limits = 10;// 获取总条数
        $count = Db::name('article')->where('cate_id','=',2)->count();//计算总页面
        $allpage = intval(ceil($count / $limits));
        $agent = new ArticleModel();
        $lists = $agent->getAgentByWhere($map, $Nowpage, $limits);
        $this->assign('Nowpage', $Nowpage); //当前页
        $this->assign('allpage', $allpage); //总页数
        $this->assign('count', $count);
        $this->assign('val', $key);
        if(input('get.page')){
            return json($lists);
        }
        return $this->fetch();
    }
    /**
     * [add_article 添加文章]
     */
    public function add_agent()
    {
        if(request()->isAjax()){

            $param = input('post.');
            $agent = new ArticleModel();
            $flag = $agent->insertAgent($param);
            return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
        }
        $cate = new ArticleCateModel();
        $this->assign('cate',$cate->getAllCate());
        return $this->fetch();
    }
    /**
     * [edit_article 编辑文章]
     */
    public function edit_agent()
    {
        $agent = new ArticleModel();

        if(request()->isAjax()){

            $param = input('post.');
            $flag = $agent->updateAgent($param);
            return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
        }
        $id = input('param.id');
        $cate = new ArticleCateModel();
        $this->assign('cate',$cate->getAllCate());
        $this->assign('agent',$agent->getOneAgent($id));
        return $this->fetch();
    }
    /**
     * [del_article 删除文章]
     */
    public function del_agent()
    {
        $id = input('param.id');
        $cate = new ArticleModel();
        $flag = $cate->delAgent($id);
        return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
    }
    /**
     * [article_state 文章状态]
     */
    public function agent_state()
    {
        $id=input('param.id');
        $status = Db::name('article')->where(array('id'=>$id))->value('status');//判断当前状态情况
        if($status==1)
        {
            $flag = Db::name('article')->where(array('id'=>$id))->setField(['status'=>0]);
            return json(['code' => 1, 'data' => $flag['data'], 'msg' => '已禁止']);
        }
        else
        {
            $flag = Db::name('article')->where(array('id'=>$id))->setField(['status'=>1]);
            return json(['code' => 0, 'data' => $flag['data'], 'msg' => '已开启']);
        }
    }
    //*********************************************新闻中心3*********************************************//
    /**
     *首页
     */
    public function register(){

        $key = input('key');
        $map = [];
        if($key&&$key!==""){
            $map['title'] = ['like',"%" . $key . "%"];
        }
        $Nowpage = input('get.page') ? input('get.page'):1;
        $limits = 10;// 获取总条数
        $count = Db::name('article')->where('cate_id','=',3)->count();//计算总页面
        $allpage = intval(ceil($count / $limits));
        $register= new ArticleModel();
        $lists = $register->getRegisterByWhere($map, $Nowpage, $limits);
        $this->assign('Nowpage', $Nowpage); //当前页
        $this->assign('allpage', $allpage); //总页数
        $this->assign('count', $count);
        $this->assign('val', $key);
        if(input('get.page')){
            return json($lists);
        }
        return $this->fetch();
    }
    /**
     * [add_article 添加文章]
     */
    public function add_register()
    {
        if(request()->isAjax()){

            $param = input('post.');
            $register = new ArticleModel();
            $flag = $register->insertRegister($param);
            return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
        }
        $cate = new ArticleCateModel();
        $this->assign('cate',$cate->getAllCate());
        return $this->fetch();
    }
    /**
     * [edit_article 编辑文章]
     */
    public function edit_register()
    {
        $register = new ArticleModel();

        if(request()->isAjax()){

            $param = input('post.');
            $flag = $register->updateAgent($param);
            return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
        }
        $id = input('param.id');
        $cate = new ArticleCateModel();
        $this->assign('cate',$cate->getAllCate());
        $this->assign('register',$register->getOneRegister($id));
        return $this->fetch();
    }
    /**
     * [del_article 删除文章]
     */
    public function del_register()
    {
        $id = input('param.id');
        $cate = new ArticleModel();
        $flag = $cate->delAgent($id);
        return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
    }
    /**
     * [article_state 文章状态]
     */
    public function register_state()
    {
        $id=input('param.id');
        $status = Db::name('article')->where(array('id'=>$id))->value('status');//判断当前状态情况
        if($status==1)
        {
            $flag = Db::name('article')->where(array('id'=>$id))->setField(['status'=>0]);
            return json(['code' => 1, 'data' => $flag['data'], 'msg' => '已禁止']);
        }
        else
        {
            $flag = Db::name('article')->where(array('id'=>$id))->setField(['status'=>1]);
            return json(['code' => 0, 'data' => $flag['data'], 'msg' => '已开启']);
        }
    }

    //*********************************************新闻中心4*********************************************//

    /**
     *首页
     */
    public function news(){

        $key = input('key');
        $map = [];
        if($key&&$key!==""){
            $map['title'] = ['like',"%" . $key . "%"];
        }
        $Nowpage = input('get.page') ? input('get.page'):1;
        $limits = 10;// 获取总条数
        $count = Db::name('article')->where('cate_id','=',4)->count();//计算总页面
        $allpage = intval(ceil($count / $limits));
        $news = new ArticleModel();
        $lists = $news->getNewsByWhere($map, $Nowpage, $limits);
        $this->assign('Nowpage', $Nowpage); //当前页
        $this->assign('allpage', $allpage); //总页数
        $this->assign('count', $count);
        $this->assign('val', $key);
        if(input('get.page')){
            return json($lists);
        }
        return $this->fetch();
    }
    /**
     * [add_article 添加文章]
     */
    public function add_news()
    {
        if(request()->isAjax()){

            $param = input('post.');
            $news = new ArticleModel();
            $flag = $news->insertNews($param);
            return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
        }
        $cate = new ArticleCateModel();
        $this->assign('cate',$cate->getAllCate());
        return $this->fetch();
    }
    /**
     * [edit_article 编辑文章]
     */
    public function edit_news()
    {
        $news = new ArticleModel();

        if(request()->isAjax()){

            $param = input('post.');
            $flag = $news->updateNews($param);
            return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
        }
        $id = input('param.id');
        $cate = new ArticleCateModel();
        $this->assign('cate',$cate->getAllCate());
        $this->assign('news',$news->getOneNews($id));
        return $this->fetch();
    }
    /**
     * [del_article 删除文章]
     */
    public function del_news()
    {
        $id = input('param.id');
        $cate = new ArticleModel();
        $flag = $cate->delNews($id);
        return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
    }
    /**
     * [article_state 文章状态]
     */
    public function news_state()
    {
        $id=input('param.id');
        $status = Db::name('article')->where(array('id'=>$id))->value('status');//判断当前状态情况
        if($status==1)
        {
            $flag = Db::name('article')->where(array('id'=>$id))->setField(['status'=>0]);
            return json(['code' => 1, 'data' => $flag['data'], 'msg' => '已禁止']);
        }
        else
        {
            $flag = Db::name('article')->where(array('id'=>$id))->setField(['status'=>1]);
            return json(['code' => 0, 'data' => $flag['data'], 'msg' => '已开启']);
        }
    }
    //*********************************************通知公告*********************************************//

    /**
     *首页
     */
    public function laws(){

        $key = input('key');
        $map = [];
        if($key&&$key!==""){
            $map['title'] = ['like',"%" . $key . "%"];
        }
        $Nowpage = input('get.page') ? input('get.page'):1;
        $limits = 10;// 获取总条数
        $count = Db::name('article')->where('cate_id','=',5)->count();//计算总页面
        $allpage = intval(ceil($count / $limits));
        $laws = new ArticleModel();
        $lists = $laws->getLawsByWhere($map, $Nowpage, $limits);
        $this->assign('Nowpage', $Nowpage); //当前页
        $this->assign('allpage', $allpage); //总页数
        $this->assign('count', $count);
        $this->assign('val', $key);
        if(input('get.page')){
            return json($lists);
        }
        return $this->fetch();
    }
    /**
     * [add_article 添加文章]
     */
    public function add_laws()
    {
        if(request()->isAjax()){

            $param = input('post.');
            $laws = new ArticleModel();
            $flag = $laws ->insertLaws($param);
            return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
        }
        $cate = new ArticleCateModel();
        $this->assign('cate',$cate->getAllCate());
        return $this->fetch();
    }
    /**
     * [edit_article 编辑文章]
     */
    public function edit_laws ()
    {
        $laws = new ArticleModel();

        if(request()->isAjax()){

            $param = input('post.');
            $flag = $laws ->updateLaws ($param);
            return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
        }
        $id = input('param.id');
        $cate = new ArticleCateModel();
        $this->assign('cate',$cate->getAllCate());
        $this->assign('laws',$laws->getOneLaws($id));
        return $this->fetch();
    }
    /**
     * [del_article 删除文章]
     */
    public function del_laws()
    {
        $id = input('param.id');
        $cate = new ArticleModel();
        $flag = $cate->delLaws($id);
        return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
    }
    /**
     * [article_state 文章状态]
     */
    public function laws_state()
    {
        $id=input('param.id');
        $status = Db::name('article')->where(array('id'=>$id))->value('status');//判断当前状态情况
        if($status==1)
        {
            $flag = Db::name('article')->where(array('id'=>$id))->setField(['status'=>0]);
            return json(['code' => 1, 'data' => $flag['data'], 'msg' => '已禁止']);
        }
        else
        {
            $flag = Db::name('article')->where(array('id'=>$id))->setField(['status'=>1]);
            return json(['code' => 0, 'data' => $flag['data'], 'msg' => '已开启']);
        }
    }
    //*********************************************公路要事*********************************************//

    /**
     *首页
     */
    public function problem(){

        $key = input('key');
        $map = [];
        if($key&&$key!==""){
            $map['title'] = ['like',"%" . $key . "%"];
        }
        $Nowpage = input('get.page') ? input('get.page'):1;
        $limits = 10;// 获取总条数
        $count = Db::name('article')->where('cate_id','=',6)->count();//计算总页面
        $allpage = intval(ceil($count / $limits));
        $problem = new ArticleModel();
        $lists = $problem->getProblemByWhere($map, $Nowpage, $limits);
        $this->assign('Nowpage', $Nowpage); //当前页
        $this->assign('allpage', $allpage); //总页数
        $this->assign('count', $count);
        $this->assign('val', $key);
        if(input('get.page')){
            return json($lists);
        }
        return $this->fetch();
    }
    /**
     * [add_article 添加文章]
     */
    public function add_problem()
    {
        if(request()->isAjax()){

            $param = input('post.');
            $problem = new ArticleModel();
            $flag = $problem ->insertProblem($param);
            return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
        }
        $cate = new ArticleCateModel();
        $this->assign('cate',$cate->getAllCate());
        return $this->fetch();
    }
    /**
     * [edit_article 编辑文章]
     */
    public function edit_problem ()
    {
        $problem = new ArticleModel();

        if(request()->isAjax()){

            $param = input('post.');
            $flag = $problem->updateProblem ($param);
            return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
        }
        $id = input('param.id');
        $cate = new ArticleCateModel();
        $this->assign('cate',$cate->getAllCate());
        $this->assign('problem',$problem->getOneProblem($id));
        return $this->fetch();
    }
    /**
     * [del_article 删除文章]
     */
    public function del_problem()
    {
        $id = input('param.id');
        $cate = new ArticleModel();
        $flag = $cate->delProblem($id);
        return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
    }
    /**
     * [article_state 文章状态]
     */
    public function problem_state()
    {
        $id=input('param.id');
        $status = Db::name('article')->where(array('id'=>$id))->value('status');//判断当前状态情况
        if($status==1)
        {
            $flag = Db::name('article')->where(array('id'=>$id))->setField(['status'=>0]);
            return json(['code' => 1, 'data' => $flag['data'], 'msg' => '已禁止']);
        }
        else
        {
            $flag = Db::name('article')->where(array('id'=>$id))->setField(['status'=>1]);
            return json(['code' => 0, 'data' => $flag['data'], 'msg' => '已开启']);
        }
    }
    //*********************************************风采展示*********************************************//

    /**
     *首页
     */
    public function mien(){

        $key = input('key');
        $map = [];
        if($key&&$key!==""){
            $map['title'] = ['like',"%" . $key . "%"];
        }
        $Nowpage = input('get.page') ? input('get.page'):1;
        $limits = 10;// 获取总条数
        $count = Db::name('article')->where('cate_id','=',7)->count();//计算总页面
        $allpage = intval(ceil($count / $limits));
        $mien = new ArticleModel();
        $lists = $mien->getMienByWhere($map, $Nowpage, $limits);
        $this->assign('Nowpage', $Nowpage); //当前页
        $this->assign('allpage', $allpage); //总页数
        $this->assign('count', $count);
        $this->assign('val', $key);
        if(input('get.page')){
            return json($lists);
        }
        return $this->fetch();
    }
    /**
     * [add_article 添加文章]
     */
    public function add_mien()
    {
        if(request()->isAjax()){

            $param = input('post.');
            $mien = new ArticleModel();
            $flag = $mien ->insertMien($param);
            return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
        }
        $cate = new ArticleCateModel();
        $this->assign('cate',$cate->getAllCate());
        return $this->fetch();
    }
    /**
     * [edit_article 编辑文章]
     */
    public function edit_mien ()
    {
        $mien = new ArticleModel();

        if(request()->isAjax()){

            $param = input('post.');
            $flag = $mien->updateMien ($param);
            return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
        }
        $id = input('param.id');
        $cate = new ArticleCateModel();
        $this->assign('cate',$cate->getAllCate());
        $this->assign('mien',$mien->getOneMien($id));
        return $this->fetch();
    }
    /**
     * [del_article 删除文章]
     */
    public function del_mien()
    {
        $id = input('param.id');
        $cate = new ArticleModel();
        $flag = $cate->delMien($id);
        return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
    }
    /**
     * [article_state 文章状态]
     */
    public function mien_state()
    {
        $id=input('param.id');
        $status = Db::name('article')->where(array('id'=>$id))->value('status');//判断当前状态情况
        if($status==1)
        {
            $flag = Db::name('article')->where(array('id'=>$id))->setField(['status'=>0]);
            return json(['code' => 1, 'data' => $flag['data'], 'msg' => '已禁止']);
        }
        else
        {
            $flag = Db::name('article')->where(array('id'=>$id))->setField(['status'=>1]);
            return json(['code' => 0, 'data' => $flag['data'], 'msg' => '已开启']);
        }
    }
    //*********************************************展会信息*********************************************//

    /**
     *首页Exhibition
     */
    public function exhibition(){

        $key = input('key');
        $map = [];
        if($key&&$key!==""){
            $map['title'] = ['like',"%" . $key . "%"];
        }
        $Nowpage = input('get.page') ? input('get.page'):1;
        $limits = 10;// 获取总条数
        $count = Db::name('article')->where('cate_id','=',8)->count();//计算总页面
        $allpage = intval(ceil($count / $limits));
        $exhibition = new ArticleModel();
        $lists = $exhibition->getExhibitionByWhere($map, $Nowpage, $limits);
        $this->assign('Nowpage', $Nowpage); //当前页
        $this->assign('allpage', $allpage); //总页数
        $this->assign('count', $count);
        $this->assign('val', $key);
        if(input('get.page')){
            return json($lists);
        }
        return $this->fetch();
    }
    /**
     * [add_article 添加文章]
     */
    public function add_exhibition()
    {
        if(request()->isAjax()){

            $param = input('post.');
            $exhibition = new ArticleModel();
            $flag = $exhibition ->insertExhibition($param);
            return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
        }
        $cate = new ArticleCateModel();
        $this->assign('cate',$cate->getAllCate());
        return $this->fetch();
    }
    /**
     * [edit_article 编辑文章]
     */
    public function edit_exhibition ()
    {
        $exhibition = new ArticleModel();

        if(request()->isAjax()){

            $param = input('post.');
            $flag = $exhibition->updateExhibition ($param);
            return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
        }
        $id = input('param.id');
        $cate = new ArticleCateModel();
        $this->assign('cate',$cate->getAllCate());
        $this->assign('exhibition',$exhibition->getOneExhibition($id));
        return $this->fetch();
    }
    /**
     * [del_article 删除文章]
     */
    public function del_exhibition()
    {
        $id = input('param.id');
        $cate = new ArticleModel();
        $flag = $cate->delExhibition($id);
        return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
    }
    /**
     * [article_state 文章状态]
     */
    public function exhibition_state()
    {
        $id=input('param.id');
        $status = Db::name('article')->where(array('id'=>$id))->value('status');//判断当前状态情况
        if($status==1)
        {
            $flag = Db::name('article')->where(array('id'=>$id))->setField(['status'=>0]);
            return json(['code' => 1, 'data' => $flag['data'], 'msg' => '已禁止']);
        }
        else
        {
            $flag = Db::name('article')->where(array('id'=>$id))->setField(['status'=>1]);
            return json(['code' => 0, 'data' => $flag['data'], 'msg' => '已开启']);
        }
    }

    //*********************************************展会信息2*********************************************//

    /**
     *首页
     */
    public function information(){

        $key = input('key');
        $map = [];
        if($key&&$key!==""){
            $map['title'] = ['like',"%" . $key . "%"];
        }
        $Nowpage = input('get.page') ? input('get.page'):1;
        $limits = 10;// 获取总条数
        $count = Db::name('article')->where('cate_id','=',8)->count();//计算总页面
        $allpage = intval(ceil($count / $limits));
        $information = new ArticleModel();
        $lists = $information->getInformationByWhere($map, $Nowpage, $limits);
        $this->assign('Nowpage', $Nowpage); //当前页
        $this->assign('allpage', $allpage); //总页数
        $this->assign('count', $count);
        $this->assign('val', $key);
        if(input('get.page')){
            return json($lists);
        }
        return $this->fetch();
    }
    /**
     * [add_article 添加文章]
     */
    public function add_information()
    {
        if(request()->isAjax()){

            $param = input('post.');
            $information = new ArticleModel();
            $flag = $information ->insertInformation($param);
            return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
        }
        $cate = new ArticleCateModel();
        $this->assign('cate',$cate->getAllCate());
        return $this->fetch();
    }
    /**
     * [edit_article 编辑文章]
     */
    public function edit_information ()
    {
        $information = new ArticleModel();

        if(request()->isAjax()){

            $param = input('post.');
            $flag = $information->updateInformation ($param);
            return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
        }
        $id = input('param.id');
        $cate = new ArticleCateModel();
        $this->assign('cate',$cate->getAllCate());
        $this->assign('information',$information->getOneInformation($id));
        return $this->fetch();
    }
    /**
     * [del_article 删除文章]
     */
    public function del_information()
    {
        $id = input('param.id');
        $cate = new ArticleModel();
        $flag = $cate->delInformation($id);
        return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
    }
    /**
     * [article_state 文章状态]
     */
    public function information_state()
    {
        $id=input('param.id');
        $status = Db::name('article')->where(array('id'=>$id))->value('status');//判断当前状态情况
        if($status==1)
        {
            $flag = Db::name('article')->where(array('id'=>$id))->setField(['status'=>0]);
            return json(['code' => 1, 'data' => $flag['data'], 'msg' => '已禁止']);
        }
        else
        {
            $flag = Db::name('article')->where(array('id'=>$id))->setField(['status'=>1]);
            return json(['code' => 0, 'data' => $flag['data'], 'msg' => '已开启']);
        }
    }


//*********************************************展会信息3*********************************************//

    /**
     *首页
     */
    public function timely(){

        $key = input('key');
        $map = [];
        if($key&&$key!==""){
            $map['title'] = ['like',"%" . $key . "%"];
        }
        $Nowpage = input('get.page') ? input('get.page'):1;
        $limits = 10;// 获取总条数
        $count = Db::name('article')->where('cate_id','=',8)->count();//计算总页面
        $allpage = intval(ceil($count / $limits));
        $timely = new ArticleModel();
        $lists = $timely->getTimelyByWhere($map, $Nowpage, $limits);
        $this->assign('Nowpage', $Nowpage); //当前页
        $this->assign('allpage', $allpage); //总页数
        $this->assign('count', $count);
        $this->assign('val', $key);
        if(input('get.page')){
            return json($lists);
        }
        return $this->fetch();
    }
    /**
     * [add_article 添加文章]
     */
    public function add_timely()
    {
        if(request()->isAjax()){

            $param = input('post.');
            $timely = new ArticleModel();
            $flag = $timely ->insertTimely($param);
            return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
        }
        $cate = new ArticleCateModel();
        $this->assign('cate',$cate->getAllCate());
        return $this->fetch();
    }
    /**
     * [edit_article 编辑文章]
     */
    public function edit_timely ()
    {
        $timely = new ArticleModel();

        if(request()->isAjax()){

            $param = input('post.');
            $flag = $timely->updateTimely ($param);
            return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
        }
        $id = input('param.id');
        $cate = new ArticleCateModel();
        $this->assign('cate',$cate->getAllCate());
        $this->assign('timely',$timely->getOneTimely($id));
        return $this->fetch();
    }
    /**
     * [del_article 删除文章]
     */
    public function del_timely()
    {
        $id = input('param.id');
        $cate = new ArticleModel();
        $flag = $cate->delTimely($id);
        return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
    }
    /**
     * [article_state 文章状态]
     */
    public function timely_state()
    {
        $id=input('param.id');
        $status = Db::name('article')->where(array('id'=>$id))->value('status');//判断当前状态情况
        if($status==1)
        {
            $flag = Db::name('article')->where(array('id'=>$id))->setField(['status'=>0]);
            return json(['code' => 1, 'data' => $flag['data'], 'msg' => '已禁止']);
        }
        else
        {
            $flag = Db::name('article')->where(array('id'=>$id))->setField(['status'=>1]);
            return json(['code' => 0, 'data' => $flag['data'], 'msg' => '已开启']);
        }
    }

//*********************************************展会信息4*********************************************//

    /**
     *首页
     */
    public function fashion(){

        $key = input('key');
        $map = [];
        if($key&&$key!==""){
            $map['title'] = ['like',"%" . $key . "%"];
        }
        $Nowpage = input('get.page') ? input('get.page'):1;
        $limits = 10;// 获取总条数
        $count = Db::name('article')->where('cate_id','=',8)->count();//计算总页面
        $allpage = intval(ceil($count / $limits));
        $fashion = new ArticleModel();
        $lists = $fashion->getFashionByWhere($map, $Nowpage, $limits);
        $this->assign('Nowpage', $Nowpage); //当前页
        $this->assign('allpage', $allpage); //总页数
        $this->assign('count', $count);
        $this->assign('val', $key);
        if(input('get.page')){
            return json($lists);
        }
        return $this->fetch();
    }
    /**
     * [add_article 添加文章]
     */
    public function add_fashion()
    {
        if(request()->isAjax()){

            $param = input('post.');
            $fashion = new ArticleModel();
            $flag = $fashion ->insertFashion($param);
            return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
        }
        $cate = new ArticleCateModel();
        $this->assign('cate',$cate->getAllCate());
        return $this->fetch();
    }
    /**
     * [edit_article 编辑文章]
     */
    public function edit_fashion ()
    {
        $fashion = new ArticleModel();

        if(request()->isAjax()){

            $param = input('post.');
            $flag = $fashion->updateFashion ($param);
            return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
        }
        $id = input('param.id');
        $cate = new ArticleCateModel();
        $this->assign('cate',$cate->getAllCate());
        $this->assign('fashion',$fashion->getOneFashion($id));
        return $this->fetch();
    }
    /**
     * [del_article 删除文章]
     */
    public function del_fashion()
    {
        $id = input('param.id');
        $cate = new ArticleModel();
        $flag = $cate->delFashion($id);
        return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
    }
    /**
     * [article_state 文章状态]
     */
    public function fashion_state()
    {
        $id=input('param.id');
        $status = Db::name('article')->where(array('id'=>$id))->value('status');//判断当前状态情况
        if($status==1)
        {
            $flag = Db::name('article')->where(array('id'=>$id))->setField(['status'=>0]);
            return json(['code' => 1, 'data' => $flag['data'], 'msg' => '已禁止']);
        }
        else
        {
            $flag = Db::name('article')->where(array('id'=>$id))->setField(['status'=>1]);
            return json(['code' => 0, 'data' => $flag['data'], 'msg' => '已开启']);
        }
    }

//*********************************************养护技术*********************************************//

    /**
     *首页technology
     */
    public function technology(){

        $key = input('key');
        $map = [];
        if($key&&$key!==""){
            $map['title'] = ['like',"%" . $key . "%"];
        }
        $Nowpage = input('get.page') ? input('get.page'):1;
        $limits = 10;// 获取总条数
        $count = Db::name('article')->where('cate_id','=',8)->count();//计算总页面
        $allpage = intval(ceil($count / $limits));
        $technology = new ArticleModel();
        $lists = $technology->getTechnologyByWhere($map, $Nowpage, $limits);
        $this->assign('Nowpage', $Nowpage); //当前页
        $this->assign('allpage', $allpage); //总页数
        $this->assign('count', $count);
        $this->assign('val', $key);
        if(input('get.page')){
            return json($lists);
        }
        return $this->fetch();
    }
    /**
     * [add_article 添加文章]
     */
    public function add_technology()
    {
        if(request()->isAjax()){

            $param = input('post.');
            $technology = new ArticleModel();
            $flag = $technology ->insertTechnology($param);
            return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
        }
        $cate = new ArticleCateModel();
        $this->assign('cate',$cate->getAllCate());
        return $this->fetch();
    }
    /**
     * [edit_article 编辑文章]
     */
    public function edit_technology ()
    {
        $technology = new ArticleModel();

        if(request()->isAjax()){

            $param = input('post.');
            $flag = $technology->updateTechnology ($param);
            return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
        }
        $id = input('param.id');
        $cate = new ArticleCateModel();
        $this->assign('cate',$cate->getAllCate());
        $this->assign('technology',$technology->getOneTechnology($id));
        return $this->fetch();
    }
    /**
     * [del_article 删除文章]
     */
    public function del_technology()
    {
        $id = input('param.id');
        $cate = new ArticleModel();
        $flag = $cate->delTechnology($id);
        return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
    }
    /**
     * [article_state 文章状态]
     */
    public function technology_state()
    {
        $id=input('param.id');
        $status = Db::name('article')->where(array('id'=>$id))->value('status');//判断当前状态情况
        if($status==1)
        {
            $flag = Db::name('article')->where(array('id'=>$id))->setField(['status'=>0]);
            return json(['code' => 1, 'data' => $flag['data'], 'msg' => '已禁止']);
        }
        else
        {
            $flag = Db::name('article')->where(array('id'=>$id))->setField(['status'=>1]);
            return json(['code' => 0, 'data' => $flag['data'], 'msg' => '已开启']);
        }
    }

//*********************************************企业专栏*********************************************//

    /**
     *首页
     */
    public function company(){

        $key = input('key');
        $map = [];
        if($key&&$key!==""){
            $map['title'] = ['like',"%" . $key . "%"];
        }
        $Nowpage = input('get.page') ? input('get.page'):1;
        $limits = 10;// 获取总条数
        $count = Db::name('article')->where('cate_id','=',8)->count();//计算总页面
        $allpage = intval(ceil($count / $limits));
        $company = new ArticleModel();
        $lists = $company->getCompanyByWhere($map, $Nowpage, $limits);
        $this->assign('Nowpage', $Nowpage); //当前页
        $this->assign('allpage', $allpage); //总页数
        $this->assign('count', $count);
        $this->assign('val', $key);
        if(input('get.page')){
            return json($lists);
        }
        return $this->fetch();
    }
    /**
     * [add_article 添加文章]
     */
    public function add_company()
    {
        if(request()->isAjax()){

            $param = input('post.');
            $company = new ArticleModel();
            $flag = $company ->insertCompany($param);
            return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
        }
        $cate = new ArticleCateModel();
        $this->assign('cate',$cate->getAllCate());
        return $this->fetch();
    }
    /**
     * [edit_article 编辑文章]
     */
    public function edit_company ()
    {
        $company = new ArticleModel();

        if(request()->isAjax()){

            $param = input('post.');
            $flag = $company->updateCompany ($param);
            return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
        }
        $id = input('param.id');
        $cate = new ArticleCateModel();
        $this->assign('cate',$cate->getAllCate());
        $this->assign('company',$company->getOneCompany($id));
        return $this->fetch();
    }
    /**
     * [del_article 删除文章]
     */
    public function del_company()
    {
        $id = input('param.id');
        $cate = new ArticleModel();
        $flag = $cate->delCompany($id);
        return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
    }
    /**
     * [article_state 文章状态]
     */
    public function company_state()
    {
        $id=input('param.id');
        $status = Db::name('article')->where(array('id'=>$id))->value('status');//判断当前状态情况
        if($status==1)
        {
            $flag = Db::name('article')->where(array('id'=>$id))->setField(['status'=>0]);
            return json(['code' => 1, 'data' => $flag['data'], 'msg' => '已禁止']);
        }
        else
        {
            $flag = Db::name('article')->where(array('id'=>$id))->setField(['status'=>1]);
            return json(['code' => 0, 'data' => $flag['data'], 'msg' => '已开启']);
        }
    }
}